package com.aspose.cells.a.d;

public class zgk {
   public static byte[] a(byte[] var0) throws Exception {
      if (e(var0)) {
         return var0;
      } else {
         try {
            com.aspose.cells.a.c.zd var1 = new com.aspose.cells.a.c.zd(var0);

            byte[] var2;
            try {
               var2 = a(var1);
            } finally {
               if (var1 != null) {
                  var1.a();
               }

            }

            return var2;
         } catch (Exception var7) {
            return com.aspose.cells.a.c.zv.h();
         }
      }
   }

   public static byte[] a(com.aspose.cells.a.c.zd var0) throws Exception {
      com.aspose.cells.b.a.d.zh var1 = new com.aspose.cells.b.a.d.zh();
      switch(var0.b()) {
      case 4:
      case 5:
      case 8:
         var0.a(var1, var0.b());
         break;
      case 6:
      default:
         var0.b(var1, 100);
         break;
      case 7:
         var0.a(var1, 5);
      }

      return com.aspose.cells.a.c.zw.a(var1, false);
   }

   private static boolean e(byte[] var0) throws Exception {
      int var1 = zbn.a(var0);
      switch(var1) {
      case 4:
         return b(var0);
      case 5:
         return c(var0);
      case 6:
      case 7:
      default:
         return false;
      case 8:
         return d(var0);
      }
   }

   public static boolean b(byte[] var0) throws Exception {
      assert zbn.d(var0);

      com.aspose.cells.b.a.d.zh var1 = new com.aspose.cells.b.a.d.zh(var0);

      try {
         zu var2 = new zu(var1);
         var2.e();
         int var3 = var2.e();

         while((var3 & '\uffff' & '\ufff0') != 65472 || (var3 & '\uffff') == 65476 || (var3 & '\uffff') == 65484) {
            switch(var3) {
            case 65504:
            case 65505:
            case 65506:
            case 65517:
            case 65518:
               boolean var4 = true;
               return var4;
            case 65507:
            case 65508:
            case 65509:
            case 65510:
            case 65511:
            case 65512:
            case 65513:
            case 65514:
            case 65515:
            case 65516:
            default:
               int var8 = var2.e();
               var1.a((long)((var8 & '\uffff') - 2), 1);
               var3 = var2.e();
            }
         }
      } finally {
         if (var1 != null) {
            var1.a();
         }

      }

      return false;
   }

   public static boolean c(byte[] var0) throws Exception {
      assert zbn.e(var0);

      com.aspose.cells.b.a.d.zh var1 = new com.aspose.cells.b.a.d.zh(var0);

      boolean var13;
      try {
         zu var2 = new zu(var1);
         byte var3 = 8;
         var1.b((long)var3);
         String var4 = "";
         String var5 = "";
         boolean var6 = true;

         while(var1.i() <= var1.h() - 8L) {
            long var7 = var2.c();
            String var9 = new String(var2.b(4));
            if (var6) {
               var4 = var9;
               var6 = false;
            }

            var5 = var9;
            var1.a((var7 & 4294967295L) + 4L, 1);
         }

         var13 = "IHDR".equals(var4) && "IEND".equals(var5);
      } finally {
         if (var1 != null) {
            var1.a();
         }

      }

      return var13;
   }

   public static boolean d(byte[] var0) throws Exception {
      assert zbn.c(var0);

      zfz var1 = new zfz(var0);
      return var1.a();
   }
}
